# -*- coding: utf-8 -*-
import yaml
import logging
import yagmail


class Tools:
    def Yaml(self, url):
        with open(url, 'r') as f:
            return yaml.safe_load(f)

    def Log(self, log):
        logging.basicConfig(
            filename=f'../Log/{log}.txt',
            filemode='w+',
            level=logging.INFO,
            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
        )

    def yagmails(self, data):
        yagmail.SMTP(
            user="liluwei321@qq.com",
            password="fsluvvlizrlkejeb",
            host="smtp.qq.com"
        ).send(
            to='liluwei321@qq.com',
            subject="a3mall测试结果",
            contents="附件为a3mall日志文件和测试报告",
            attachments=data
        )
